package com.demo.core.model;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.demo.core.model.support.SimpleBaseModel;

/**
 * 站点配置模型类
 */
public class Config extends SimpleBaseModel implements java.io.Serializable {
	/**
	 * 版本序列化ID
	 */
	private static final long serialVersionUID = 9077219241978979543L;
	
	/**
	 * 内置
	 */
	public static final String CONFIG_TYPE_INLAY = "INLAY";
	
	/**
	 * 站点自定义
	 */
	public static final String CONFIG_TYPE_SITE = "SITE";
	
	/**
	 * 用户自定义
	 */
	public static final String CONFIG_TYPE_USER = "USER";
	
	/**
	 * 配置状态：正常
	 */
	public static final String STATUS_NORMAL = "normal";
	
	/**
	 * 配置状态：隐藏
	 */
	public static final String STATUS_HIDE = "hide";
	
	/**
	 * 站点外键ID
	 */
	private Long siteId;
	
	/**
	 * 配置title
	 */
	private String title;
	
	/**
	 * 配置的名字
	 */
	private String name;
	
	/**
	 * 配置值
	 */
	private String value;
	
	/**
	 * 是否可用
	 */
	private Boolean enabled;
	
	/**
	 * 配置类型：内置、管理员自定义、用户自定义等；
	 */
	private String type;
	
	/**
	 * 字典的状态，是否使用，隐藏
	 */
	private String status;
	
	/**
	 * 配置的国际化
	 */
	private String i18n;
	
	/**
	 * 优先级
	 */
	private int priority;
	
	/**
	 * 配置子项内容列表
	 */
	private List<ConfigItem> configItemList;
	
	/**
	 * 配置子项内容Map
	 */
	private Map<String, ConfigItem> configItemMap;
	
	public Long getSiteId() {
		return siteId;
	}
	public void setSiteId(Long siteId) {
		this.siteId = siteId;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	public String getI18n() {
		return i18n;
	}
	public void setI18n(String i18n) {
		this.i18n = i18n;
	}
	public int getPriority() {
		return priority;
	}
	public void setPriority(int priority) {
		this.priority = priority;
	}
	public String getValue() {
		return value;
	}
	public void setValue(String value) {
		this.value = value;
	}
	public Boolean isEnabled() {
		return enabled;
	}
	public void setEnabled(Boolean enabled) {
		this.enabled = enabled;
	}
	public List<ConfigItem> getConfigItemList() {
		return configItemList;
	}
	public void setConfigItemList(List<ConfigItem> configItemList) {
		this.configItemList = configItemList;
	}
	public Map<String, ConfigItem> getConfigItemMap() {
		return this.configItemMap;
	}
	public void setConfigItemMap(Map<String, ConfigItem> configItemMap) {
		this.configItemMap = configItemMap;
	}
	public void initConfigItemMap() {
		if (configItemList != null) {
			if (configItemMap == null) {
				configItemMap = new HashMap<String, ConfigItem>();
			}
			for (ConfigItem item : configItemList) {
				if (!configItemMap.containsKey(item.getKey())) {
					configItemMap.put(item.getKey(), item);
				}
			}
		}
	}
}